#
# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
#
# -*- mode: python; -*-

import platform
Import('BuildEnv')
env = BuildEnv.Clone()

def MapBuildDir(list):
    return map(lambda x: '#/' + Dir('..').path + '/../' + x, list)

env.Prepend(CPPPATH = env['TOP'] + '/../include/thrift')
env.Prepend(CPPPATH = env['TOP'] + '/schema')
env.Prepend(CPPPATH = env['TOP'] + '/ifmap')
env.Prepend(CPPPATH = env['TOP'] + '/sandesh/library')
env.Prepend(CPPPATH = '#/third_party/thrift-0.8.0/lib/cpp/src/')

env.Prepend(LIBS=['thrift','xmpp', 'peer_sandesh',
                  'xmpp_unicast', 'xmpp_multicast', 'services',
                  'xml', 'pugixml', 'route',
                  'bgp_schema', 'ifmap_vnc', 'ifmap_agent', 'ifmap_common',
                  'ifmapio',
                  'sandeshflow', 'sandesh', 'http', 'http_parser', 'curl',
                  'process_info', 'db', 'base', 'task_test', 'io', 'sandeshvns', 'net',
                  'ssl', 'crypto', 'gunit', 'boost_regex', 'boost_filesystem',
                  'cpuinfo', 'pugixml'])

if platform.system() != 'Darwin':
    if platform.system() == 'Windows':
        env.Append(LIBS = ['advapi32', 'gdi32', 'user32'])
    else:
        env.Append(LIBS=['rt'])
    env.Prepend(LIBS=['ksync', 'ksyncnl'])

libs = MapBuildDir(['db', 'bgp', 'xmpp', 'xml', 'pugixml', 'io', 'ksync',
                    'base', 'base/test', 'boost_regex', 'route', 'schema',
                    'ifmap', 'net', 'net'])

env.Append(LIBPATH=libs)

ksync_test = env.Program('ksync_test', ['ksync_test.cc'])
env.Alias('src/ksync:ksync_test', ksync_test)

ksync_db_test = env.Program('ksync_db_test', ['ksync_db_test.cc'])
env.Alias('src/ksync:ksync_db_test', ksync_db_test)

test_suite = [
    ksync_test,
    ksync_db_test,
    ]

test = env.TestSuite('ksync-base-test', test_suite)
env.Alias('controller/src/ksync:test', test)
